package audit;

import java.util.ArrayList;

import fileProcessing.ParsingException;

import main.Main;

public class StatFunctions {
	
	protected ArrayList<Double> valuesList;
	
	public StatFunctions(ArrayList<Double> list){
		valuesList = list;
	}
	
	public double getMaxDeviation(){
		int length = valuesList.size();
		double stats;
		double mean = calcMean();
		double sumDevSQrd = calcSumOfSquaredDeviations(mean);
		double stdDeviation = Math.sqrt(sumDevSQrd/(length-1));
		//printValues();
		stats = mean+stdDeviation;
		return stats;
	}
	
	private double calcMean(){
		double sum=0.00;
		for(Double i : valuesList){
			sum+=i;
		}
		return sum/valuesList.size();
	}
	private double calcSumOfSquaredDeviations(double mean){
		double deviationsSqrd=0.00;
		for(Double i : valuesList){
			deviationsSqrd+= Math.pow((mean-i),2);
		}
		return deviationsSqrd;
	}
}
